import { _decorator, Component, Node, tween, UIOpacity } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('UIBase')
export abstract class UIBase extends Component {
    private op: UIOpacity = null;

    onLoad(): void {
        this.op = this.getComponent(UIOpacity);
    }

    onShow() {
        tween(this.op).to(0.1, { opacity: 255 }).start();
    }

    onHide(active: boolean = false) {
        tween(this.op)
            .to(0.1, { opacity: 0 })
            .call(() => {
                this.node.active = active;
            })
            .start();
    }
}


